from drg_group.yinchuan_2023.Base import message,intersect,SS_VALID
from drg_group.yinchuan_2023.DRG import MDCB_DRG

def group(record):
  adrg_zd=["C79.400x013","G45.002","G45.004","G45.100x002","G45.800x003","G45.800x004","G45.801","G45.900","G93.501","I60.000x003","I60.000x007","I60.001","I60.100","I60.101","I60.200x002","I60.200x003","I60.200x005","I60.201","I60.301","I60.400x003","I60.401","I60.600x004","I60.701","I60.800x002","I61.100x001","I63.100","I63.102","I63.201","I63.203","I63.204","I63.205","I63.207","I63.208","I63.300","I63.302","I63.402","I63.500","I63.501","I63.502","I63.900","I63.902","I63.904","I63.905","I63.906","I63.907","I65.001","I65.002","I65.101","I65.200x001","I65.201","I65.203","I66.001","I66.002","I66.901","I67.100x005","I67.100x021","I67.100x023","I67.100x026","I67.103","I67.107","I67.108","I67.110","I67.802","I69.300","I69.300x002","I69.300x003","I72.000x035","I72.000x036","I72.500x002","I72.600x002","Q28.200"]
  adrg_zd1=[]
  adrg_ss=["00.5501","00.6101","00.6102","00.6200x005","00.6200x008","00.6200x009","00.6201","00.6300","00.6300x005","00.6300x006","00.6300x007","00.6301","00.6400x009","00.6400x013","00.6500x008","00.6501","39.7200x007","39.7201","39.7203","39.7205","39.7206","39.7208","39.7209","39.7213","39.7400x002","39.7400x004","39.7401","39.7501","39.7503","39.7504","39.7506","39.9008"]
  adrg_ss1=[]
  adrg_ss2=[]
  dept_list=[]
  if True and record.zdList[0] in adrg_zd and record.ssList and record.ssList[0] in adrg_ss and record.ssList and intersect(record.ssList,adrg_ss):
    message('符合BE2入组条件，匹配规则：主诊断匹配、主手术匹配、某一手术匹配')
    
    if MDCB_DRG.BE29_group(record):
      return 'BE29'

    return 'BE2'
  else:
    return ''

